array([1.41421356,2.,3.,4.])
1.0
1.0
-1.0
array([1.,1.,2.,3.,1.,-1.,-2.])
array([1.,2.71828183,148.4131591])
array([10,15,17,26,13,19,12,11,21,24,14,23])
array([[10,15,17,26,13,19],
[12,11,21,24,14,23]])
array([[10,15,17,26],
[13,19,12,11],
[21,24,14,23]])
array([[10,15,17,26,13,19],
[12,11,21,24,14,23]])
[array([[10,15,17],
[12,11,21]]),
array([[26,13,19],
[24,14,23]])]
#examplesonuniversalfunctions
#importingimportantlibraries
importpandasaspd
importnumpyasnp
#numbersforwhichsquarerootwillbecalculated
np_sqrt=np.sqrt([2,4,9,16])
#squarerootvalues
np_sqrt
#importpi
fromnumpyimportpi
#trigonometricfunctions
np.cos(0)
#trigonometricfunctions
np.sin(pi/2)
#trigonometricfunctions
np.cos(pi)
#returntheflooroftheinputelementwise
np.floor([1.5,1.6,2.7,3.3,1.1,-0.3,-1.4])
#exponentialfunctionsforcomplexmathematicalcalculations
np.exp([0,1,5])
#importingtherequiredlibraries
importpandasaspd
importnumpyasnp
#shapemanipulationexamples
#createdthenewvariablethatisnew_cyclist_trials
new_cyclist_trials=np.array([[10,15,17,26,13,19],[12,11,21,24,14,23]])
#flattensthedataset
new_cyclist_trials.ravel()
#seentheoutputfornew_cyclist_trials
new_cyclist_trials
#changesorreshapesthedatasetinto3rowsand4columns
new_cyclist_trials.reshape(3,4)
#resizingthedatasetinto2rowsand6columns
new_cyclist_trials.resize(2,6)
#checkingtheoutputinto2rowsand6columns
new_cyclist_trials
#splittingthearrayintotwo
np.hsplit(new_cyclist_trials,2)
#createdthenewvariablecallednew_cyclist_1
array([12,11,21,24,14,23,12,11,21,24,14,23])
[12345]
array([0.,0.,0.])
array([[0.,0.,0.],
[0.,0.,0.],
[0.,0.,0.]])
array([[1.,1.,1.],
[1.,1.,1.],
[1.,1.,1.]])
array([[0.,0.,0.],
[0.,0.,0.]])
[01234567891011]
array([[0,1,2,3],
[4,5,6,7],
[8,9,10,11]])
array([1.,2.25,3.5,4.75,6.])
[01234567891011121314]
#createdthenewvariablecallednew_cyclist_1
new_cyclist_1=np.array([10,15,17,26,13,19])
#createdthenewvariablecallednew_cyclist_2
new_cyclist_2=np.array([12,11,21,24,14,23])
#stacksthearraytogether
#herewehavecombinedthenew_cyclist_1andnew_cyclist_2
np.hstack((new_cyclist_1,new_cyclist_2))
#firstnumpyarray
#thisistheregulararray:mentionarrayelementswithinthesquarebrackets
first_numpy_array=np.array([1,2,3,4,5])
#printingthe1starray
print(first_numpy_array)
#arraywithzeros
#zerosarray;mentionshapeofthearraywithinparentheses
#alwaysdoublebracketisused
array_with_zeros=np.zeros((3))
array_with_zeros
#arraywithzeros
array_with_zeros=np.zeros((3,3))
array_with_zeros
#arraywithones
array_with_ones=np.ones((3,3))
array_with_ones
#arraywithempty
array_with_empty=np.empty((2,3))
array_with_empty
#arraywitharangemathod
np_arange=np.arange(12)
#printingtherangebyarangemethod
print(np_arange)
#reshpemethodtochnageorcreteanarray
np_arange.reshape(3,4)
#linspceforlinearly,equalspaceddataelements
#herefirstelementis1,lastelementis6andthetotalnumberofequidistantelementis5
np_linspace=np.linspace(1,6,5)
#printingtheelements
np_linspace
#onedimenssionalarray
oneD_array=np.arange(15)
#printingtheonedimensionalarray
print(oneD_array)
#twodimensionalarray
[[01234]
[56789]
[1011121314]]
array([[[0,1,2],
[3,4,5],
[6,7,8]],
[[9,10,11],
[12,13,14],
[15,16,17]],
[[18,19,20],
[21,22,23],
[24,25,26]]])
0luxemburg
1norway
2japan
3swizerland
4unitedstates
5qatar
6iceland
7sweden
8singapore
9denmark
dtype:object
china1.1
japan2.2
america3.3
europe4.4
goa5.5
cst6.6
mumbai7.7
australia8.8
maldives9.9
dtype:float64
twoD_array=oneD_array.reshape(3,5)
#printingtheelementsoftwodimensioanlarray
print(twoD_array)
#threedimensionalarray
ThreeD_array=np.arange(27).reshape(3,3,3)
#printingtheelementsofthreedimensioanlarray
ThreeD_array
#createseriesfromndarray
#wehavecreatedthendarraythatmeansonedimensionalarrayforcountries
#wehavecreatedthenewvariablecallednp_country
np_country=np.array(['luxemburg','norway','japan','swizerland',
'unitedstates','qatar','iceland','sweden','singapore','denmark'])
#passndarrayasanarguement
np_country=pd.Series(np_country)
#printingtheelementsofthenp_country
#herethedatatypeidobject
print(np_country)
#createseriesfromdictonary
#evaluatecountriesandtheircorrespondinggdppercapitaandprintthemasaseries
#herethecountrieshasbeenpassedasanindexandgdpastheactualdatavalue
#dictionaryforcountriesandtheirgdp
dict_country_gdp=pd.Series([1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9],index=['china','japan',
'america','europe','goa',
'cst','mumbai','australia'
,'maldives'])
#thisdisplaysthegdpwiththecountries
#herethedatatypeisfloat
print(dict_country_gdp)
#printserieswithscalerinput
#herewehavegiventhescalarinput
#giventheindexlikea,b,c,d,e
scalar_Series=pd.Series(5.,index=['a','b','c','d','e'])
#herewehaveobservedtheindexasa,b,c,d,eandthedataofthatindex
#herethedatatypeisfloat
scalar_Series
a5.0
b5.0
c5.0
d5.0
e5.0
dtype:float64
1.1
china1.1
japan2.2
america3.3
europe4.4
goa5.5
dtype:float64
9.9
1.1
a11
b22
c33
d44
dtype:int64
a11
b22
c33
d44
dtype:int64
a11.0
b22.0
cNaN
dNaN
eNaN
fNaN
dtype:float64
#accessingelementsinseries
#datacanbeaccessedthroughdifferentfunctionslikeloc
#ilocbypassingthedataelementspositionorindexrange
#accesselementsintheseries
dict_country_gdp[0]
#accessfirstfivecountriesfromtheseries
#herewehavegiven0:5meansthatmeanswewillbegettingtotal5values
dict_country_gdp[0:5]
#lookupacountrybyanameoranindex
dict_country_gdp.loc['maldives']
#lookupbyanposition
dict_country_gdp.iloc[0]
#vectorizedoperationsinseries
#vectorizedoperationsareperformedbythedataelementsposition
#herewehaveaddtheseries
first_vector_Series=pd.Series([1,2,3,4],index=['a','b','c','d'])
second_vector_Series=pd.Series([10,20,30,40],index=['a','b','c','d'])
#herewehaveaddedfirst_vector_Seriesandsecond_vector_Series
first_vector_Series+second_vector_Series
#herewehaveonlyransecond_vector_Series
second_vector_Series=pd.Series([10,20,30,40],index=['a','b','c','d'])
#butherewehaveaddedboththefirst_vector_Seriesandsecond_vector_Seriesbutafteraddingtheresultwillbesame
first_vector_Series+second_vector_Series
#nowreplacefewindexeswithnewoneinsecondvectorseries
second_vector_Series=pd.Series([10,20,30,40],index=['a','b','e','f'])
#herethevalueforc,d,e,fisNANaswehaveremovedtheelemntsfromindex
first_vector_Series+second_vector_Series
#createdataframefromndarray
#creatingdataframefromdictofndarray
#importingnumpylibrary
importnumpyasnp
#createanndarrayswithyears
#createadictwiththendarray
np_array=np.array([2012,2008,2004,2006])
dict_ndarray={'year':np_array}
year
0 2012
1 2008
2 2004
3 2006
(83,42)
UPDATED ENTRY_DATE EVENT_LCL_DATE EVENT_LCL_TIME LOC_CITY_NAME LOC_STATE_NAME LOC_CNTRY_NAME RMK_TEXT EVENT_TYPE_DESC
0 No 19-FEB-16 19-FEB-16 00:45:00Z MARSHVILLE NorthCarolina NaN
AIRCRAFT
CRASHED
INTOTREES,
THE1
PERSONON
B...
1 No 19-FEB-16 18-FEB-16 23:55:00Z TAVERNIER Florida NaN
AIRCRAFT
ONLANDING
WENTOFF
THEENDOF
THERU...
2 No 19-FEB-16 18-FEB-16 22:14:00Z TRENTON NewJersey NaN
AIRCRAFT
ONFINAL
SUSTAINED
ABIRD
STRIKE,
LAN...
3 No 19-FEB-16 18-FEB-16 17:10:00Z ASHEVILLE NorthCarolina NaN
AIRCRAFT
ON
LANDING,
GEAR
COLLAPSED,
ASHEVILLE...
4 No 19-FEB-16 18-FEB-16 00:26:00Z TALKEETNA Alaska NaN
AIRCRAFT
ON
LANDING,
NOSEGEAR
COLLAPSED,
TALK...
5rows×42columns
Index(['UPDATED','ENTRY_DATE','EVENT_LCL_DATE','EVENT_LCL_TIME',
'LOC_CITY_NAME','LOC_STATE_NAME','LOC_CNTRY_NAME','RMK_TEXT',
'EVENT_TYPE_DESC','FSDO_DESC','REGIST_NBR','FLT_NBR','ACFT_OPRTR',
'ACFT_MAKE_NAME','ACFT_MODEL_NAME','ACFT_MISSING_FLAG',
'ACFT_DMG_DESC','FLT_ACTIVITY','FLT_PHASE','FAR_PART','MAX_INJ_LVL',
'FATAL_FLAG','FLT_CRW_INJ_NONE','FLT_CRW_INJ_MINOR',
'FLT_CRW_INJ_SERIOUS','FLT_CRW_INJ_FATAL','FLT_CRW_INJ_UNK',
'CBN_CRW_INJ_NONE','CBN_CRW_INJ_MINOR','CBN_CRW_INJ_SERIOUS',
'CBN_CRW_INJ_FATAL','CBN_CRW_INJ_UNK','PAX_INJ_NONE','PAX_INJ_MINOR',
'PAX_INJ_SERIOUS','PAX_INJ_FATAL','PAX_INJ_UNK','GRND_INJ_NONE',
'GRND_INJ_MINOR','GRND_INJ_SERIOUS','GRND_INJ_FATAL','GRND_INJ_UNK'],
dtype='object')
#passthedicttothenewdataframe
df_ndarray=pd.DataFrame(dict_ndarray)
#printingtheonedimensioanlarraythatisndarray
#itwillcreateanewdataframelistingalltheyears
df_ndarray
#importlibrary
importpandasaspd
importnumpyasnp
#readthefaathatisfederalavaiationauthoritydataset
df_faa_dataset=pd.read_csv("faa_ai_prelim.csv")
#viewtheshapeofthedataset
df_faa_dataset.shape
#viewthefirstfiveobservations
df_faa_dataset.head()
#viewallthecolumnspresentinthedataset
df_faa_dataset.columns
#howtocreateanewdataframewithonlyrequiredcolumns
df_analyze_dataset=df_faa_dataset[['ACFT_MAKE_NAME','LOC_STATE_NAME','ACFT_MODEL_NAME','RMK_TEXT',
'FLT_PHASE','EVENT_TYPE_DESC','FATAL_FLAG']]
#viewthetypeoftheobject
pandas.core.frame.DataFrame
ACFT_MAKE_NAME LOC_STATE_NAME ACFT_MODEL_NAME RMK_TEXT FLT_PHASE EVENT_TYPE_DESC FATAL_FLAG
0 BEECH NorthCarolina 36
AIRCRAFTCRASHED
INTOTREES,THE1
PERSONONB...
UNKNOWN
(UNK)
Accident Yes
1 VANS Florida RV7
AIRCRAFTON
LANDINGWENTOFF
THEENDOFTHE
RU...
LANDING
(LDG)
Incident NaN
2 CESSNA NewJersey 172
AIRCRAFTONFINAL
SUSTAINEDABIRD
STRIKE,LAN...
APPROACH
(APR)
Incident NaN
3 LANCAIR NorthCarolina 235
AIRCRAFTON
LANDING,GEAR
COLLAPSED,
ASHEVILLE...
LANDING
(LDG)
Incident NaN
4 CESSNA Alaska 172
AIRCRAFTON
LANDING,NOSE
GEARCOLLAPSED,
TALK...
LANDING
(LDG)
Incident NaN
C:\Users\Ankita\AppData\Local\Temp\ipykernel_26596\173567365.py:2:SettingWithCopyWarning:
AvalueistryingtobesetonacopyofaslicefromaDataFrame
Seethecaveatsinthedocumentation:https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#ret
urning-a-view-versus-a-copy
df_analyze_dataset['FATAL_FLAG'].fillna(value='No',inplace=True)
ACFT_MAKE_NAME LOC_STATE_NAME ACFT_MODEL_NAME RMK_TEXT FLT_PHASE EVENT_TYPE_DESC FATAL_FLAG
0 BEECH NorthCarolina 36
AIRCRAFTCRASHED
INTOTREES,THE1
PERSONONB...
UNKNOWN
(UNK)
Accident Yes
1 VANS Florida RV7
AIRCRAFTON
LANDINGWENTOFF
THEENDOFTHE
RU...
LANDING
(LDG)
Incident No
2 CESSNA NewJersey 172
AIRCRAFTONFINAL
SUSTAINEDABIRD
STRIKE,LAN...
APPROACH
(APR)
Incident No
3 LANCAIR NorthCarolina 235
AIRCRAFTON
LANDING,GEAR
COLLAPSED,
ASHEVILLE...
LANDING
(LDG)
Incident No
4 CESSNA Alaska 172
AIRCRAFTON
LANDING,NOSE
GEARCOLLAPSED,
TALK...
LANDING
(LDG)
Incident No
(83,7)
(78,7)
#viewthetypeoftheobject
type(df_analyze_dataset)
#viewfirstfiveobservations
df_analyze_dataset.head()
#replaceallNaNforfatalflagwith'no'
df_analyze_dataset['FATAL_FLAG'].fillna(value='No',inplace=True)
#nowviewfirstfiveobservations
df_analyze_dataset.head()
#viewtheshapeofthedataset
df_analyze_dataset.shape
#dropthevalueswhereACFT_MAKE_NAMEthatisaircraftmakenameisnotavailable
df_final_dataset=df_analyze_dataset.dropna(subset=['ACFT_MAKE_NAME'])
#nowviewthenewshapeofthedataset
df_final_dataset.shape
#groupbyaircraftname
aircraftType=df_final_dataset.groupby('ACFT_MAKE_NAME')
#viewthembyaircraftusingsizemethod
aircraftType.size()
#thisisthelistofalltheaircraftstypesandthenumberoftimestheyappearinthedataset.
ACFT_MAKE_NAME
AEROCOMMANDER1
AERONCA1
AEROSTARINTERNATIONAL1
AIRBUS1
BEECH9
BELL2
BOEING3
CESSNA23
CHAMPION2
CHRISTEN1
CONSOLIDATEDVULTEE1
EMBRAER1
ENSTROM1
FAIRCHILD1
FLIGHTDESIGN1
GLOBE1
GREATLAKES1
GRUMMAN1
GULFSTREAM1
HUGHES1
LANCAIR2
MAULE1
MOONEY4
NORTHAMERICAN1
PIPER10
PITTS1
SAAB1
SABRELINER1
SOCATA2
VANS1
dtype:int64
FATAL_FLAG
No71
Yes7
dtype:int64
ACFT_MAKE_NAME LOC_STATE_NAME ACFT_MODEL_NAME RMK_TEXT FLT_PHASE EVENT_TYPE_DESC FATAL_FLAG
0 BEECH NorthCarolina 36
AIRCRAFT
CRASHEDINTO
TREES,THE1
PERSONONB...
UNKNOWN
(UNK)
Accident Yes
53 PIPER Florida PA28
AIRCRAFT
CRASHEDUNDER
UNKNOWN
CIRCUMSTANCES.
...
UNKNOWN
(UNK)
Accident Yes
55 FLIGHTDESIGN California CTLS
AIRCRAFT
CRASHEDUNDER
UNKNOWN
CIRCUMSTANCES
A...
UNKNOWN
(UNK)
Accident Yes
79 NORTHAMERICAN Arizona F51
AIRCRAFT
CRASHEDUNDER
UNKNOWN
CIRCUMSTANCES,
...
UNKNOWN
(UNK)
Accident Yes
80 CHAMPION California 8KCAB
N9872R,BEECHM35
AIRCRAFT,AND
N5057G,BELLAN...
UNKNOWN
(UNK)
Accident Yes
81 BEECH California 35
N9872R,BEECHM35
AIRCRAFT,AND
N5057G,BELLAN...
UNKNOWN
(UNK)
Accident Yes
82 CESSNA Alabama 182
N784CPAIRCRAFT
CRASHEDINTOA
WOODEDAREA
NEA...
UNKNOWN
(UNK)
Accident Yes
#nowgroupthedatasetbyfatalflag
fatalAccidents=df_final_dataset.groupby('FATAL_FLAG')
#viewthetotalaccidentssize
fatalAccidents.size()
#selecttheaccidentswithfatalitywithfatalflagyes
accidents_with_fatality=fatalAccidents.get_group('Yes')
#viewtheaccidentswithfatality
accidents_with_fatality
#importinglibraries
importpandasaspd
importnumpyasnp
#readthedatafromcsvfilefiredepartmentofnewyorkcitythatisFDNY
<boundmethodNDFrame.describeofFacilityName\
0FacilityName
1Engine4/Ladder15
2Engine10/Ladder10
3Engine6
4Engine7/Ladder1/Battalion1/ManhattanBoroug...
.....
214Engine162/Ladder82/Battalion23
215Engine167/Ladder87
216Engine164/Ladder84
217Engine168/EMSStation23
218Engine151/Ladder76
FacilityAddressBorough
0FacilityAddressBorough
142SouthStreetManhattan
2124LibertyStreetManhattan
349BeekmanStreetManhattan
4100-104DuaneStreetManhattan
........
214256NelsonAvenueStatenIsland
215345AnnadaleRoadStatenIsland
2161560DrumgooleRoadWestStatenIsland
2171100RossvilleAvenueStatenIsland
2187219AmboyRoadStatenIsland
[219rowsx3columns]>
FacilityName FacilityAddress Borough
0 FacilityName FacilityAddress Borough
1 Engine4/Ladder15 42SouthStreet Manhattan
2 Engine10/Ladder10 124LibertyStreet Manhattan
3 Engine6 49BeekmanStreet Manhattan
4 Engine7/Ladder1/Battalion1/ManhattanBoroug... 100-104DuaneStreet Manhattan
FacilityName FacilityAddress Borough
0 Engine4/Ladder15 42SouthStreet Manhattan
1 Engine10/Ladder10 124LibertyStreet Manhattan
2 Engine6 49BeekmanStreet Manhattan
3 Engine7/Ladder1/Battalion1/ManhattanBoroug... 100-104DuaneStreet Manhattan
4 Ladder8 14NorthMooreStreet Manhattan
FacilityName FacilityAddress Borough
count 218 218 218
unique 218 218 5
top Engine4/Ladder15 42SouthStreet Brooklyn
freq 1 1 66
Index(['FacilityName','FacilityAddress','Borough'],dtype='object')
RangeIndex(start=0,stop=218,step=1)
#readthedatafromcsvfilefiredepartmentofnewyorkcitythatisFDNY
df_fdny_csv_data_raw=pd.read_csv("FDNY.csv")
#viewcontentofthedata
df_fdny_csv_data_raw.describe
#viewfirstfiverecords
df_fdny_csv_data_raw.head(5)
#skipthefirstrowfromthedataset
df_fdny_csv_data=pd.read_csv('FDNY.csv',skiprows=1)
#viewfirstfiverecordsfromthefixeddataset
df_fdny_csv_data.head()
#viewdatastatisticsusingdescribe
df_fdny_csv_data.describe()
#viewcoulmnsofthedataset
df_fdny_csv_data.columns
#viewindexofthedataset
df_fdny_csv_data.index
#countnumberofrecords
FacilityName218
FacilityAddress218
Borough218
dtype:int64
FacilityNameobject
FacilityAddressobject
Boroughobject
dtype:object
Borough
Bronx34
Brooklyn66
Manhattan48
Queens50
StatenIsland20
dtype:int64
#countnumberofrecords
#herearethetotalnumberoffiredepartmentfacilities
df_fdny_csv_data.count()
#viewdatatypes
df_fdny_csv_data.dtypes
#selectFDNYinformationboroughwise
groupby_borough=df_fdny_csv_data.groupby('Borough')
#viewFDNYinformationboroughwise
#thisarethenumberoffiredepartmentsfacilitiesineachborough
groupby_borough.size()
#selectFDNYinformationforManhattan
fdny_info_Manhattan=groupby_borough.get_group('Manhattan')
#viewFDNYinformationforManhattan
fdny_info_Manhattan
FacilityName FacilityAddress Borough
0 Engine4/Ladder15 42SouthStreet Manhattan
1 Engine10/Ladder10 124LibertyStreet Manhattan
2 Engine6 49BeekmanStreet Manhattan
3 Engine7/Ladder1/Battalion1/ManhattanBoroug... 100-104DuaneStreet Manhattan
4 Ladder8 14NorthMooreStreet Manhattan
5 Engine9/Ladder6 75CanalStreet Manhattan
6 Engine15/Ladder18/Battalion4 25PittStreet Manhattan
7 Engine28/Ladder11 222East2ndStreet Manhattan
8 Engine5 340East14thStreet Manhattan
9 Engine55 363BroomeStreet Manhattan
10 Ladder20/Division1 253LafayetteStreet Manhattan
11 Engine24/Ladder5/Battalion2 227-296thAvenue Manhattan
12 Engine33/Ladder9 42GreatJonesStreet Manhattan
13 Ladder3/Battalion6 108East13thStreet Manhattan
14 Squad18 132West10thStreet Manhattan
15 Engine34/Ladder21 440West38thStreet Manhattan
16 Engine26 220West37thStreet Manhattan
17 Engine3/Ladder12/Battalion7 150West19thStreet Manhattan
18 Engine1/Ladder24 142-46West31stStreet Manhattan
19 Engine14 14East18thStreet Manhattan
20 Engine16/Ladder7 234East29thStreet Manhattan
21 Engine21 238East40thStreet Manhattan
22 Engine54/Ladder4/Battalion9 7828thAvenue Manhattan
23 Engine23 215West58thStreet Manhattan
24 Rescue1 530West43rdStreet Manhattan
25 Engine40/Ladder35 131AmsterdamAvenue Manhattan
26 Ladder25/DistrictOffice4/Division3 205-207West77thStreet Manhattan
27 Engine74 120West83rdStreet Manhattan
28 Engine65 33West43rdStreet Manhattan
29 Engine8/Ladder2/Battalion8 167East51stStreet Manhattan
30 Engine39/Ladder16 157-59East67thStreet Manhattan
31 Engine44 221East75thStreet Manhattan
32 Engine22/Ladder13/Battalion10 159East85thStreet Manhattan
33 Engine58/Ladder26 13675thAvenue Manhattan
34 Engine53/Ladder43 1836-463rdAvenue Manhattan
35 Engine91 242East111thStreet Manhattan
36 Engine35/Ladder14 22823rdAvenue Manhattan
37 Engine76/Ladder22/Battalion11 145-51West100thStreet Manhattan
38 Engine47 502West113thStreet Manhattan
39 Engine59/Ladder30 111West133rdStreet Manhattan
40 Engine37/Ladder40 415West125thStreet Manhattan
41 Engine69/Ladder28/Battalion16 248West143rdStreet Manhattan
42 Engine80/Ladder23 503West139thStreet Manhattan
43 Engine84/Ladder34 513West161stStreet Manhattan
44 Engine67 518West170thStreet Manhattan
45 Engine93/Ladder45/Battalion13 515West181stStreet Manhattan
46 Engine95/Ladder36 29VermilyeaAvenue Manhattan
47 Marine1 LittleWest12thStreet/HudsonRiver Manhattan
#importimportantlibraries
importmatplotlib.pyplotasplt
%matplotlibinline
#datafromohiostate,leadingcausesofdeathinthestatefromyear2012
#causesofdeath
cause='ChronicDiseases','UnintentionalInjuries','Alzheimers','InfluenzaandPneumonia',
array([24.,6.])
'Sepsis','Others'
#percentile
percentile=[62,5,4,2,1,26]
#setthepiechartplotproperties
#setfiguresize
plt.figure(figsize=(10,10))
#explodethelargestpieinthedataset
#explodemeansgapbetweenthepiechartblocks
explode=(0.05,0,0,0,0,0)
#setpiechartproperties
#autopct='%1.1f%%'-thisisforbettervisualization
plt.pie(percentile,labels=cause,explode=explode,autopct='%1.1f%%',startangle=70)
#setaxisequaltodrawpieascircle
plt.axis('equal')
#settitleofthepiechart
plt.title('OhioState-2012:LeadingCausesofDeath')
#showtheplotthatispiechart
plt.show()
#importimportantlibrraies
importnumpyasnp
fromscipyimportlinalg
#testhas30questionsandworth150marks
#trueandfalsequestionsworth4markseach
#multiplechoicequestionsworth9markseach
#letxisthenumberoftrue/falsequestions
#letyisthenumberofmultiplechoicequestions
#(x+y=30)
#(4x+9y=150)
testQuestionVariable=np.array([[1,1],[4,9]])
testQuestionValue=np.array([30,150])
#uselinalgfunctionofscipy
#usesolvemethodtosolvethelinearequationandfindvalueforxandy
linalg.solve(testQuestionVariable,testQuestionValue)
#importingrequiredlibraries
Unnamed:0 TVAdBudget($) RadioAdBudget($) NewspaperAdBudget($) Sales($)
0 1 230.1 37.8 69.2 22.1
1 2 44.5 39.3 45.1 10.4
2 3 17.2 45.9 69.3 9.3
3 4 151.5 41.3 58.5 18.5
4 5 180.8 10.8 58.4 12.9
1000
(200,5)
Index(['Unnamed:0','TVAdBudget($)','RadioAdBudget($)',
'NewspaperAdBudget($)','Sales($)'],
dtype='object')
NewspaperAdBudget($) Sales($) RadioAdBudget($)
0 69.2 22.1 37.8
1 45.1 10.4 39.3
2 69.3 9.3 45.9
3 58.5 18.5 41.3
4 58.4 12.9 10.8
Sales($)
0 22.1
1 10.4
2 9.3
3 18.5
4 12.9
(200,3)
(200,1)
#importingrequiredlibraries
importpandasaspd
#importingtheadvertisingdataset
df_adv_data=pd.read_csv("Advertising.csv")
#viewthetop5records
df_adv_data.head()
#viewthedatasetsize
df_adv_data.size
#viewtheshapeofthedataset
df_adv_data.shape
#viewthecolumnsofthedataset
df_adv_data.columns
#createafeatureobjectfromthecolumns
X_feature=df_adv_data[['NewspaperAdBudget($)','Sales($)','RadioAdBudget($)']]
#viewfeatureobject
X_feature.head()
#createtargetobjectfromsalescolumnwhichisaresponseinthedataset
Y_target=df_adv_data[['Sales($)']]
#viewthetargetobject
Y_target.head()
#viewthefeatureobjectshape
X_feature.shape
#viewthetargetobjectshape
Y_target.shape
#splittestandtrainingdata
#bydefault75%trainingdataand25%testingdata
#splitastrainandtestdataset
(150,3)
(150,1)
(50,3)
(50,1)
LinearRegression()
[-3.55271368e-15]
[[0.00000000e+001.00000000e+00-9.04990991e-17]]
array([[23.8],
[16.6],
[9.5],
[14.8],
[17.6],
[25.5],
[16.9],
[12.9],
[10.5],
[17.1],
[14.5],
[11.3],
[17.4],
[16.7],
[13.4],
[15.9],
[12.9],
[12.8],
[9.5],
[18.4],
[10.7],
[12.5],
[8.5],
[11.5],
[11.9],
[14.9],
[10.1],
[18.9],
[19.6],
[15.9],
[23.2],
[11.9],
[17.3],
[11.7],
[20.2],
[15.5],
[11.5],
[11.],
[22.3],
[7.6],
[5.3],
[8.7],
[6.7],
[19.],
[5.5],
[14.6],
[14.6],
[21.5],
[22.6],
[19.7]])
fromsklearn.model_selectionimporttrain_test_split
x_train,x_test,y_train,y_test=train_test_split(X_feature,Y_target,random_state=1)
#viewtheshapeofthetrainandtestdatasetsforbothfeatureandresponse
print(x_train.shape)
print(y_train.shape)
print(x_test.shape)
print(y_test.shape)
#linearregressionmodel
#thisisthecodetocreatealinearregressionmodelwhichwillpredictthesalesoutcomeforany
#newdata
fromsklearn.linear_modelimportLinearRegression
linreg=LinearRegression()
linreg.fit(x_train,y_train)
#printtheinterceptandcoeffiecients
print(linreg.intercept_)
print(linreg.coef_)
#prediction
y_pred=linreg.predict(x_test)
y_pred
#importrequiredlibrariesforcalculatingMSEthatismeansquareerror
fromsklearnimportmetrics
1.833179602832606e-15
['html',
<htmlitemscope=""itemtype="http://schema.org/WebPage"lang="en-IN"><head><metacontent="text/html;charset=u
tf-8"http-equiv="Content-Type"/><metacontent="/images/branding/googleg/1x/googleg_standard_color_128dp.png"i
temprop="image"/><title>Google</title><scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">(function(){window.google={kEI:'W5
6uY5C4Ou7S1sQPn_6M6Ag',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,1129120,1197703,698,380090,16114,28682,110
9,21324,1361,12318,17581,4998,13228,3847,10623,22740,2370,2711,1593,1279,2742,149,1103,841,2196,4101,108,4011,2
023,2297,14670,3227,2845,7,4774,20215,4086,4695,1851,15756,3,576,1014,1,5444,149,11323,2652,4,1528,2304,7039,22
023,5708,7355,13660,4437,16786,5824,2533,4094,4052,3,3541,1,14263,27891,2,14022,2715,23024,5679,1021,2377,28745
,4567,6256,23421,1252,5835,14968,4332,8,7476,445,2,2,1,6959,3998,15675,8155,7381,2,1478,14490,872,19634,7,1922,
5784,3995,21391,388,9543,4832,23189,3314,15605,4532,14,82,3890,757,8686,6194,679,1622,782,997,668,3183,1125,174
6,2041,4264,937,5903,1742,813,1224,10,280,2350,1497,2,32,531,909,82,1001,1094,350,90,399,96,426,1034,42,291,225
9,410,1649,1410,20,3,261,606,136,789,420,915,290,135,1304,246,951,841,1378,947,857,74,29,203,1561,1422,149,234,
71,3,539,77,9,512,326,226,156,327,9,323,50,53,166,6,258,767,184,394,1087,164,1088,5,342,460,433,284,130,108,463
,2,215,85,161,72,119,10,447,174,1068,69,857,340,500,62,118,1274,97,1,1139,1570,49,8,538,529,77,101,38,425,36,12
,105,1372,532,890,345,278,427,1199,104,191,218,544,196,3222,111,4,53,4,40,2,355,17,179,87,1689,417,654,620,756,
5272650,4190,8799060,3311,141,795,19735,1,1,346,3645,5,17,23946817,4042143,1964,16672,3406,5595,11,3834,6974,22
4',kBL:'Dl4b'};google.sn='webhp';google.kHL='en-IN';})();(function(){
varf=this||self;varh,k=[];functionl(a){for(varb;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.pare
ntNode;returnb||h}functionm(a){for(varb=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNo
de;returnb}
functionn(a,b,c,d,g){vare="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+=
"&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_20
4")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(go
ogle.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");returnc};h=google.kEI;google.getEI=l;google.getLEI=m;go
ogle.ml=function(){returnnull};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=newImage;vare=k.length;k[
e]=a;a.onerror=a.onload=a.onabort=function(){deletek[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){g
oogle.y={};google.sy=[];google.x=function(a,b){if(a)varc=a.id;else{doc=Math.random();while(google.y[c])}googl
e.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.p
ush.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=func
tion(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
document.documentElement.addEventListener("submit",function(b){vara;if(a=b.target){varc=a.getAttribute("data
-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}elsea=!1;a&&(b.preventDefault(),b.stopPropagation
())},!0);document.documentElement.addEventListener("click",function(b){vara;a:{for(a=b.target;a&&a!==document.
documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");breaka}a=!1}a&&b.p
reventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px!important;}#gba
r{height:22px}#guser{padding-bottom:7px!important;text-align:right}.gbh,.gbd{border-top:1pxsolid#c9d7f1;font
-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@mediaall{.gb1{height:22px;margin-right:.5em;ver
tical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline!important}a.gb1,a.gb4{color:#00c!impo
rtant}.gbi.gb4{color:#dd8e27!important}.gbf.gb4{color:#900!important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px8p
x0}td{line-height:.8em}.gac_mtd{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold
;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18pxarial,sans-serif}.gsfs{font:17pxarial,san
s-serif}.ds{display:inline-box;display:inline-block;margin:3px04px;margin-left:4px}input{font-family:inherit}
body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline
}.fla{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblca{display:block;margin:2px0;margin-le
ft:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid1px;border-color:#dadce0#70757a#70757a#dadce0;h
eight:30px}.lsbb{display:block}#WqQANba{display:inline-block;margin:012px}.lsb{background:url(/images/nav_log
o229.png)0-261pxrepeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15pxaria
l,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><scriptnonce="a
9fEDiXswLfU_nPTDCFxVQ">(function(){window.google.erd={jsr:1,bv:1702,de:true};
varh=this||self;vark,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=fun
ction(a,b,d,m,e){e=void0===e?2:e;b&&(r=a&&a.message);if(google.dl)returngoogle.dl(a,e,d),null;if(0>v){window.
console&&console.error(a,d);if(-2===v)throwa;b=!1}elseb=!a||!a.message||"Errorloadingscript"===a.message||q
>=l&&!m?!1:!0;if(!b)returnnull;q++;d=d||{};b=encodeURIComponent;varc="/gen_204?atyp=i&ei="+b(google.kEI);goog
le.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);varf=a.l
ineNumber;void0!==f&&(c+="&line="+f);varg=
a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.
importnumpyasnp
#calculatetheMSEthatismeansquareerror
print(np.sqrt(metrics.mean_squared_error(y_test,y_pred)))
#importrequiredlibrraies
#herebs4isthelibraryfromwhichweareimportingtheBeautifulSoup
#wearealsoimportingrequests
frombs4importBeautifulSoup
importrequests
#urlforwebscrapping
url='https://www.google.com'
#accesstheurlwithrequestobject
result=requests.get(url)
#scrapthewebpagecontent
webpage=result.content
#createasoupobjectforparsingthewebpageusingthehtmlparser
#heresiisthesoupobjectcreatedforparsingwebpageusingHTMLparser.
sl_soup=BeautifulSoup(webpage,'html.parser')
#closetheresultobject
result.close()
#viewthecontentofthesoupobject
sl_soup.contents
documentElement.outerHTML.split("\n")[f],c+="&cad="+b(f?f.substring(0,300):"Noscriptfound.")));c+="&jsel="+e;
for(varuind)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+":"+a.message);c=c+"&jsst="+b(a.stack||"
N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);returna};window.onerror=function(a,b,d,
m,e){r!==a&&(a=einstanceofError?e:Error(a),void0===d||"lineNumber"ina||(a.lineNumber=d),void0===b||"fileNa
me"ina||(a.fileName=b),google.ml(a,!1,void0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,
11)||-1!==a.message.indexOf("Scripterror")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><
bodybgcolor="#fff"><scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">(function(){varsrc='/images/nav_logo229.png';varie
sg=false;document.body.onload=function(){window.n&&window.n();if(document.images){newImage().src=src;}
if(!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();</script><divid="mngb"><divid="gbar"><nobr><bclass="gb1">Search</b><aclass="gb1"href="https://www.g
oogle.co.in/imghp?hl=en&amp;tab=wi">Images</a><aclass="gb1"href="https://maps.google.co.in/maps?hl=en&amp;ta
b=wl">Maps</a><aclass="gb1"href="https://play.google.com/?hl=en&amp;tab=w8">Play</a><aclass="gb1"href="ht
tps://www.youtube.com/?tab=w1">YouTube</a><aclass="gb1"href="https://news.google.com/?tab=wn">News</a><acl
ass="gb1"href="https://mail.google.com/mail/?tab=wm">Gmail</a><aclass="gb1"href="https://drive.google.com/?
tab=wo">Drive</a><aclass="gb1"href="https://www.google.co.in/intl/en/about/products?tab=wh"style="text-deco
ration:none"><u>More</u>»</a></nobr></div><divid="guser"width="100%"><nobr><spanclass="gbi"id="gbn"></span
><spanclass="gbf"id="gbf"></span><spanid="gbe"></span><aclass="gb4"href="http://www.google.co.in/history/o
ptout?hl=en">WebHistory</a>|<aclass="gb4"href="/preferences?hl=en">Settings</a>|<aclass="gb4"href="htt
ps://accounts.google.com/ServiceLogin?hl=en&amp;passive=true&amp;continue=https://www.google.com/&amp;ec=GAZAAQ
"id="gb_70"target="_top">Signin</a></nobr></div><divclass="gbh"style="left:0"></div><divclass="gbh"style
="right:0"></div></div><center><brclear="all"id="lgpd"/><divid="lga"><imgalt="Google"height="92"id="hplog
o"src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png"style="padding:28px014
px"width="272"/><br/><br/></div><formaction="/search"name="f"><tablecellpadding="0"cellspacing="0"><trval
ign="top"><tdwidth="25%"></td><tdalign="center"nowrap=""><inputname="ie"type="hidden"value="ISO-8859-1"/
><inputname="hl"type="hidden"value="en-IN"/><inputname="source"type="hidden"value="hp"/><inputname="biw"
type="hidden"/><inputname="bih"type="hidden"/><divclass="ds"style="height:32px;margin:4px0"><inputautocom
plete="off"class="lst"maxlength="2048"name="q"size="57"style="margin:0;padding:5px8px06px;vertical-alig
n:top;color:#000"title="GoogleSearch"value=""/></div><brstyle="line-height:0"/><spanclass="ds"><spanclass
="lsbb"><inputclass="lsb"name="btnG"type="submit"value="GoogleSearch"/></span></span><spanclass="ds"><spa
nclass="lsbb"><inputclass="lsb"id="tsuid_1"name="btnI"type="submit"value="I'mFeelingLucky"/><scriptnon
ce="a9fEDiXswLfU_nPTDCFxVQ">(function(){varid='tsuid_1';document.getElementById(id).onclick=function(){if(t
his.form.q.value){this.checked=1;if(this.form.iflsig)this.form.iflsig.disabled=false;}
elsetop.location='/doodles/';};})();</script><inputname="iflsig"type="hidden"value="AJiK0e8AAAAAY66saynM6y
5vedlsP9n8spYspos9TpGQ"/></span></span></td><tdalign="left"class="flsblc"nowrap=""width="25%"><ahref="/ad
vanced_search?hl=en-IN&amp;authuser=0">Advancedsearch</a></td></tr></table><inputid="gbv"name="gbv"type="hi
dden"value="1"/><scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">(function(){vara,b="1";if(document&&document.getElemen
tById)if("undefined"!=typeofXMLHttpRequest)b="2";elseif("undefined"!=typeofActiveXObject){varc,d,e=["MSXML2
.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{newActiveXObjec
t(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){varf=google.gbvu,g=document.getEle
mentById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></fo
rm><divid="gac_scont"></div><divstyle="font-size:83%;min-height:3.5em"><br/><divid="prm"><style>.szppmdbYutt
__middle-slot-promo{font-size:small;margin-bottom:32px}.szppmdbYutt__middle-slot-promoa.ZIeIlb{display:inline-
block;text-decoration:none}.szppmdbYutt__middle-slot-promoimg{border:none;margin-right:5px;vertical-align:midd
le}</style><divclass="szppmdbYutt__middle-slot-promo"data-ved="0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40QnIcBCAQ"><spa
n>Lookbackontheyearbyexploringthe</span><aclass="NKcBbd"href="https://www.google.com/url?q=https://ab
out.google/stories/year-in-search/%3Futm_source%3Dgoogle%26utm_medium%3Dhpp%26utm_campaign%3DIndia_yis22&amp;so
urce=hpp&amp;id=19033112&amp;ct=3&amp;usg=AOvVaw1jtvJixqyHY8bvEFRJBZJz&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZ
UCHR8_A40Q8IcBCAU"rel="nofollow">Searchtrendsof2022</a></div></div><divid="gws-output-pages-elements-homep
age_additional_languages__als"><style>#gws-output-pages-elements-homepage_additional_languages__als{font-size:s
mall;margin-bottom:24px}#SIvCob{color:#3c4043;display:inline-block;line-height:28px;}#SIvCoba{padding:03px;}.
H6sW5{display:inline-block;margin:02px;white-space:nowrap}.z4hgWe{display:inline-block;margin:02px}</style><d
ivid="SIvCob">Googleofferedin:<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3
D&amp;hl=hi&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAc"></a><ahref="htt
ps://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=bn&amp;source=homepage&amp;sa=X&amp;ve
d=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAg">ÊÚ¢ÑÚ</a><ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHL
LGQLOG94MzmSLnNs%3D&amp;hl=te&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAk">
</a><ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=mr&amp;source=home
page&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAo"></a><ahref="https://www.google.com/setpre
fs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=ta&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZU
CHR8_A40Q2ZgBCAs"></a><ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl
=gu&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAw"></a><ahref="https://w
ww.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=kn&amp;source=homepage&amp;sa=X&amp;ved=0ahU
KEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA0">
</a><ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG9
4MzmSLnNs%3D&amp;hl=ml&amp;source=homepage&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA4"></a
><ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=pa&amp;source=homepage&a
mp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA8"></a></div></div></div><spanid="footer"><divsty
le="font-size:10pt"><divid="WqQANb"style="margin:19pxauto;text-align:center"><ahref="/intl/en/ads/">Adverti
singPrograms</a><ahref="http://www.google.co.in/services/">BusinessSolutions</a><ahref="/intl/en/about.html
">AboutGoogle</a><ahref="https://www.google.com/setprefdomain?prefdom=IN&amp;prev=https://www.google.co.in/&a
mp;sig=K_O4lVvevQ8ETHggdm4IPsN1gvOO8%3D">Google.co.in</a></div></div><pstyle="font-size:8pt;color:#70757a">©2
022-<ahref="/intl/en/policies/privacy/">Privacy</a>-<ahref="/intl/en/policies/terms/">Terms</a></p></span
></center><scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">(function(){window.google.cdo={height:757,width:1440};(functio
n(){vara=window.innerWidth,b=window.innerHeight;if(!a||!b){varc=window.document,d="CSS1Compat"==c.compatMode?
c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&go
ogle.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script><scriptn
once="a9fEDiXswLfU_nPTDCFxVQ">(function(){google.xjs={ck:'xjs.hp.p8DkCBvnKaU.L.X.O',cs:'ACT90oEuqRwZ040I9nEMS4I
YPnzYYjWa8A',excm:[]};})();</script><scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">(function(){varu='/xjs/_/js/k\x3dx
js.hp.en.7AA-NzBVWyE.O/am\x3dAADoBABQAGAB/d\x3d1/ed\x3d1/rs\x3dACT90oFVO7j3BrFQavFg7OxlpNPTe6mLsA/m\x3dsb_he,d'
;varamd=0;
vard=this||self,e=function(a){returna};varg;varl=function(a,b){this.g=b===h?a:""};l.prototype.toString=fun
ction(){returnthis.g+""};varh={};
functionm(){vara=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}
functionp(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");varb=document;varc
="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void0===g){b=nu
ll;vark=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,cre
ateScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}elseg=b}a=(b=g)?b.createScriptURL(a):a;a=n
ewl(a,h);c.src=ainstanceofl&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";varf,n;(f=(a=null==(n=(f
=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void0:n.call(f,"script[nonce]
"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa
=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){returnm()},amd):m()},0);})();function_D
umpException(e){throwe;}
function_F_installCss(c){}
(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',
injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var
pmc='{\x22d\x22:{},\x22sb_he\x22:{\x22agen\x22:true,\x22cgen\x22:true,\x22client\x22:\x22heirloom-hp\x22,\x22dh
\x22:true,\x22ds\x22:\x22\x22,\x22fl\x22:true,\x22host\x22:\x22google.com\x22,\x22jsonp\x22:true,\x22msgs\x22:{
\x22cibl\x22:\x22ClearSearch\x22,\x22dym\x22:\x22Didyoumean:\x22,\x22lcky\x22:\x22I\\u0026#39;mFeelingLuck
y\x22,\x22lml\x22:\x22Learnmore\x22,\x22psrc\x22:\x22Thissearchwasremovedfromyour\\u003Cahref\x3d\\\x22
/history\\\x22\\u003EWebHistory\\u003C/a\\u003E\x22,\x22psrl\x22:\x22Remove\x22,\x22sbit\x22:\x22Searchbyima
ge\x22,\x22srch\x22:\x22GoogleSearch\x22},\x22ovr\x22:{},\x22pq\x22:\x22\x22,\x22rfs\x22:[],\x22sbas\x22:\x220
3px8px0rgba(0,0,0,0.2),0001pxrgba(0,0,0,0.08)\x22,\x22stok\x22:\x22UdorWn8zN7uFOhQEJGQfbUY7oSI\x22}}';go
ogle.pmc=JSON.parse(pmc);})();</script></body></html>]
<!DOCTYPEhtml>
<htmlitemscope=""itemtype="http://schema.org/WebPage"lang="en-IN">
<head>
<metacontent="text/html;charset=utf-8"http-equiv="Content-Type"/>
<metacontent="/images/branding/googleg/1x/googleg_standard_color_128dp.png"itemprop="image"/>
<title>
Google
</title>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){window.google={kEI:'W56uY5C4Ou7S1sQPn_6M6Ag',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,11291
20,1197703,698,380090,16114,28682,1109,21324,1361,12318,17581,4998,13228,3847,10623,22740,2370,2711,1593,1279,2
742,149,1103,841,2196,4101,108,4011,2023,2297,14670,3227,2845,7,4774,20215,4086,4695,1851,15756,3,576,1014,1,54
44,149,11323,2652,4,1528,2304,7039,22023,5708,7355,13660,4437,16786,5824,2533,4094,4052,3,3541,1,14263,27891,2,
14022,2715,23024,5679,1021,2377,28745,4567,6256,23421,1252,5835,14968,4332,8,7476,445,2,2,1,6959,3998,15675,815
5,7381,2,1478,14490,872,19634,7,1922,5784,3995,21391,388,9543,4832,23189,3314,15605,4532,14,82,3890,757,8686,61
94,679,1622,782,997,668,3183,1125,1746,2041,4264,937,5903,1742,813,1224,10,280,2350,1497,2,32,531,909,82,1001,1
094,350,90,399,96,426,1034,42,291,2259,410,1649,1410,20,3,261,606,136,789,420,915,290,135,1304,246,951,841,1378
,947,857,74,29,203,1561,1422,149,234,71,3,539,77,9,512,326,226,156,327,9,323,50,53,166,6,258,767,184,394,1087,1
64,1088,5,342,460,433,284,130,108,463,2,215,85,161,72,119,10,447,174,1068,69,857,340,500,62,118,1274,97,1,1139,
1570,49,8,538,529,77,101,38,425,36,12,105,1372,532,890,345,278,427,1199,104,191,218,544,196,3222,111,4,53,4,40,
2,355,17,179,87,1689,417,654,620,756,5272650,4190,8799060,3311,141,795,19735,1,1,346,3645,5,17,23946817,4042143
,1964,16672,3406,5595,11,3834,6974,224',kBL:'Dl4b'};google.sn='webhp';google.kHL='en-IN';})();(function(){
varf=this||self;varh,k=[];functionl(a){for(varb;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.paren
tNode;returnb||h}functionm(a){for(varb=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNod
e;returnb}
functionn(a,b,c,d,g){vare="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="
&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204
")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(goo
gle.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");returnc};h=google.kEI;google.getEI=l;google.getLEI=m;goo
gle.ml=function(){returnnull};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=newImage;vare=k.length;k[e
]=a;a.onerror=a.onload=a.onabort=function(){deletek[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){go
ogle.y={};google.sy=[];google.x=function(a,b){if(a)varc=a.id;else{doc=Math.random();while(google.y[c])}google
.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.pu
sh.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=funct
ion(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
document.documentElement.addEventListener("submit",function(b){vara;if(a=b.target){varc=a.getAttribute("data-
submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}elsea=!1;a&&(b.preventDefault(),b.stopPropagation(
))},!0);document.documentElement.addEventListener("click",function(b){vara;a:{for(a=b.target;a&&a!==document.d
ocumentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");breaka}a=!1}a&&b.pr
eventDefault()},!0);}).call(this);
</script>
<style>
#gbar,#guser{font-size:13px;padding-top:1px!important;}#gbar{height:22px}#guser{padding-bottom:7px!importa
nt;text-align:right}.gbh,.gbd{border-top:1pxsolid#c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24
px;width:100%}@mediaall{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{te
xt-decoration:underline!important}a.gb1,a.gb4{color:#00c!important}.gbi.gb4{color:#dd8e27!important}.gbf.g
b4{color:#900!important}
</style>
<style>
body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px8px0}td{line-h
eight:.8em}.gac_mtd{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:n
ormal}.lst{height:25px;width:496px}.gsfi,.lst{font:18pxarial,sans-serif}.gsfs{font:17pxarial,sans-serif}.ds{d
isplay:inline-box;display:inline-block;margin:3px04px;margin-left:4px}input{font-family:inherit}body{backgrou
nd:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fla{color:
#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblca{display:block;margin:2px0;margin-left:13px;font-
size:11px}.lsbb{background:#f8f9fa;border:solid1px;border-color:#dadce0#70757a#70757a#dadce0;height:30px}.l
sbb{display:block}#WqQANba{display:inline-block;margin:012px}.lsb{background:url(/images/nav_logo229.png)0-
261pxrepeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15pxarial,sans-serif;
vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}
</style>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){window.google.erd={jsr:1,bv:1702,de:true};
varh=this||self;vark,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=func
tion(a,b,d,m,e){e=void0===e?2:e;b&&(r=a&&a.message);if(google.dl)returngoogle.dl(a,e,d),null;if(0>v){window.c
onsole&&console.error(a,d);if(-2===v)throwa;b=!1}elseb=!a||!a.message||"Errorloadingscript"===a.message||q>
=l&&!m?!1:!0;if(!b)returnnull;q++;d=d||{};b=encodeURIComponent;varc="/gen_204?atyp=i&ei="+b(google.kEI);googl
e.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);varf=a.li
neNumber;void0!==f&&(c+="&line="+f);varg=
a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.d
ocumentElement.outerHTML.split("\n")[f],c+="&cad="+b(f?f.substring(0,300):"Noscriptfound.")));c+="&jsel="+e;f
or(varuind)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+":"+a.message);c=c+"&jsst="+b(a.stack||"N
#useprettifymethodtoviewallformattedoutputslikeHTMLtags
print(sl_soup.prettify())
/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);returna};window.onerror=function(a,b,d,m
,e){r!==a&&(a=einstanceofError?e:Error(a),void0===d||"lineNumber"ina||(a.lineNumber=d),void0===b||"fileNam
e"ina||(a.fileName=b),google.ml(a,!1,void0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,1
1)||-1!==a.message.indexOf("Scripterror")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();
</script>
</head>
<bodybgcolor="#fff">
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){varsrc='/images/nav_logo229.png';variesg=false;document.body.onload=function(){window.n&&w
indow.n();if(document.images){newImage().src=src;}
if(!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();
</script>
<divid="mngb">
<divid="gbar">
<nobr>
<bclass="gb1">
Search
</b>
<aclass="gb1"href="https://www.google.co.in/imghp?hl=en&amp;tab=wi">
Images
</a>
<aclass="gb1"href="https://maps.google.co.in/maps?hl=en&amp;tab=wl">
Maps
</a>
<aclass="gb1"href="https://play.google.com/?hl=en&amp;tab=w8">
Play
</a>
<aclass="gb1"href="https://www.youtube.com/?tab=w1">
YouTube
</a>
<aclass="gb1"href="https://news.google.com/?tab=wn">
News
</a>
<aclass="gb1"href="https://mail.google.com/mail/?tab=wm">
Gmail
</a>
<aclass="gb1"href="https://drive.google.com/?tab=wo">
Drive
</a>
<aclass="gb1"href="https://www.google.co.in/intl/en/about/products?tab=wh"style="text-decoration:none">
<u>
More
</u>
»
</a>
</nobr>
</div>
<divid="guser"width="100%">
<nobr>
<spanclass="gbi"id="gbn">
</span>
<spanclass="gbf"id="gbf">
</span>
<spanid="gbe">
</span>
<aclass="gb4"href="http://www.google.co.in/history/optout?hl=en">
WebHistory
</a>
|
<aclass="gb4"href="/preferences?hl=en">
Settings
</a>
|
<aclass="gb4"href="https://accounts.google.com/ServiceLogin?hl=en&amp;passive=true&amp;continue=https://
www.google.com/&amp;ec=GAZAAQ"id="gb_70"target="_top">
Signin
</a>
</nobr>
</div>
<divclass="gbh"style="left:0">
</div>
<divclass="gbh"style="right:0">
</div>
</div>
<center>
<brclear="all"id="lgpd"/>
<divid="lga">
<imgalt="Google"height="92"id="hplogo"src="/images/branding/googlelogo/1x/googlelogo_white_background_c
olor_272x92dp.png"style="padding:28px014px"width="272"/>
<br/>
<br/>
</div>
<formaction="/search"name="f">
<tablecellpadding="0"cellspacing="0">
<trvalign="top">
<tdwidth="25%">
</td>
<tdalign="center"nowrap="">
<inputname="ie"type="hidden"value="ISO-8859-1"/>
<inputname="hl"type="hidden"value="en-IN"/>
<inputname="source"type="hidden"value="hp"/>
<inputname="biw"type="hidden"/>
<inputname="bih"type="hidden"/>
<divclass="ds"style="height:32px;margin:4px0">
<inputautocomplete="off"class="lst"maxlength="2048"name="q"size="57"style="margin:0;padding:5px8
px06px;vertical-align:top;color:#000"title="GoogleSearch"value=""/>
</div>
<brstyle="line-height:0"/>
<spanclass="ds">
<spanclass="lsbb">
<inputclass="lsb"name="btnG"type="submit"value="GoogleSearch"/>
</span>
</span>
<spanclass="ds">
<spanclass="lsbb">
<inputclass="lsb"id="tsuid_1"name="btnI"type="submit"value="I'mFeelingLucky"/>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){varid='tsuid_1';document.getElementById(id).onclick=function(){if(this.form.q.value){
this.checked=1;if(this.form.iflsig)this.form.iflsig.disabled=false;}
elsetop.location='/doodles/';};})();
</script>
<inputname="iflsig"type="hidden"value="AJiK0e8AAAAAY66saynM6y5vedlsP9n8spYspos9TpGQ"/>
</span>
</span>
</td>
<tdalign="left"class="flsblc"nowrap=""width="25%">
<ahref="/advanced_search?hl=en-IN&amp;authuser=0">
Advancedsearch
</a>
</td>
</tr>
</table>
<inputid="gbv"name="gbv"type="hidden"value="1"/>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){vara,b="1";if(document&&document.getElementById)if("undefined"!=typeofXMLHttpRequest)b="2";e
lseif("undefined"!=typeofActiveXObject){varc,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"
,"Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{newActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.s
earch.indexOf("&gbv=2")){varf=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout
(function(){location.href=f},0)};}).call(this);
</script>
</form>
<divid="gac_scont">
</div>
<divstyle="font-size:83%;min-height:3.5em">
<br/>
<divid="prm">
<style>
.szppmdbYutt__middle-slot-promo{font-size:small;margin-bottom:32px}.szppmdbYutt__middle-slot-promoa.ZIeI
lb{display:inline-block;text-decoration:none}.szppmdbYutt__middle-slot-promoimg{border:none;margin-right:5px;v
ertical-align:middle}
</style>
<divclass="szppmdbYutt__middle-slot-promo"data-ved="0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40QnIcBCAQ">
<span>
Lookbackontheyearbyexploringthe
</span>
<aclass="NKcBbd"href="https://www.google.com/url?q=https://about.google/stories/year-in-search/%3Futm_s
ource%3Dgoogle%26utm_medium%3Dhpp%26utm_campaign%3DIndia_yis22&amp;source=hpp&amp;id=19033112&amp;ct=3&amp;usg=
AOvVaw1jtvJixqyHY8bvEFRJBZJz&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q8IcBCAU"rel="nofollow">
Searchtrendsof2022
</a>
</div>
</div>
<divid="gws-output-pages-elements-homepage_additional_languages__als">
<style>
#gws-output-pages-elements-homepage_additional_languages__als{font-size:small;margin-bottom:24px}#SIvCob{
color:#3c4043;display:inline-block;line-height:28px;}#SIvCoba{padding:03px;}.H6sW5{display:inline-block;margi
n:02px;white-space:nowrap}.z4hgWe{display:inline-block;margin:02px}
</style>
<divid="SIvCob">
Googleofferedin:
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=hi&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAc">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=bn&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAg">
ÊÚ¢ÑÚ
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=te&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAk">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=mr&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAo">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=ta&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAs">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=gu&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCAw">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=kn&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA0">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=ml&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA4">
</a>
<ahref="https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&amp;hl=pa&amp;source=homepa
ge&amp;sa=X&amp;ved=0ahUKEwjQ0fq-86D8AhVuqZUCHR8_A40Q2ZgBCA8">
</a>
</div>
</div>
</div>
<spanid="footer">
<divstyle="font-size:10pt">
<divid="WqQANb"style="margin:19pxauto;text-align:center">
<ahref="/intl/en/ads/">
AdvertisingPrograms
</a>
<ahref="http://www.google.co.in/services/">
BusinessSolutions
</a>
<ahref="/intl/en/about.html">
AboutGoogle
</a>
<ahref="https://www.google.com/setprefdomain?prefdom=IN&amp;prev=https://www.google.co.in/&amp;sig=K_O4l
VvevQ8ETHggdm4IPsN1gvOO8%3D">
Google.co.in
</a>
</div>
</div>
<pstyle="font-size:8pt;color:#70757a">
©2022-
<ahref="/intl/en/policies/privacy/">
Privacy
</a>
-
<ahref="/intl/en/policies/terms/">
Terms
</a>
</p>
</span>
</center>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){window.google.cdo={height:757,width:1440};(function(){vara=window.innerWidth,b=window.innerHeig
ht;if(!a||!b){varc=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.c
lientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&
bih="+b+"&ei="+google.kEI);}).call(this);})();
</script>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){google.xjs={ck:'xjs.hp.p8DkCBvnKaU.L.X.O',cs:'ACT90oEuqRwZ040I9nEMS4IYPnzYYjWa8A',excm:[]};})();
</script>
<scriptnonce="a9fEDiXswLfU_nPTDCFxVQ">
(function(){varu='/xjs/_/js/k\x3dxjs.hp.en.7AA-NzBVWyE.O/am\x3dAADoBABQAGAB/d\x3d1/ed\x3d1/rs\x3dACT90oFVO7
j3BrFQavFg7OxlpNPTe6mLsA/m\x3dsb_he,d';varamd=0;
vard=this||self,e=function(a){returna};varg;varl=function(a,b){this.g=b===h?a:""};l.prototype.toString=func
tion(){returnthis.g+""};varh={};
functionm(){vara=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}
functionp(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");varb=document;varc=
"SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void0===g){b=nul
l;vark=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,crea
teScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}elseg=b}a=(b=g)?b.createScriptURL(a):a;a=ne
wl(a,h);c.src=ainstanceofl&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";varf,n;(f=(a=null==(n=(f=
(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void0:n.call(f,"script[nonce]"
))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=
!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){returnm()},amd):m()},0);})();function_Du
mpException(e){throwe;}
function_F_installCss(c){}
(function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',i
njt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){varp
mc='{\x22d\x22:{},\x22sb_he\x22:{\x22agen\x22:true,\x22cgen\x22:true,\x22client\x22:\x22heirloom-hp\x22,\x22dh\
x22:true,\x22ds\x22:\x22\x22,\x22fl\x22:true,\x22host\x22:\x22google.com\x22,\x22jsonp\x22:true,\x22msgs\x22:{\
x22cibl\x22:\x22ClearSearch\x22,\x22dym\x22:\x22Didyoumean:\x22,\x22lcky\x22:\x22I\\u0026#39;mFeelingLucky
\x22,\x22lml\x22:\x22Learnmore\x22,\x22psrc\x22:\x22Thissearchwasremovedfromyour\\u003Cahref\x3d\\\x22/
history\\\x22\\u003EWebHistory\\u003C/a\\u003E\x22,\x22psrl\x22:\x22Remove\x22,\x22sbit\x22:\x22Searchbyimag
e\x22,\x22srch\x22:\x22GoogleSearch\x22},\x22ovr\x22:{},\x22pq\x22:\x22\x22,\x22rfs\x22:[],\x22sbas\x22:\x220
3px8px0rgba(0,0,0,0.2),0001pxrgba(0,0,0,0.08)\x22,\x22stok\x22:\x22UdorWn8zN7uFOhQEJGQfbUY7oSI\x22}}';go
ogle.pmc=JSON.parse(pmc);})();
</script>
</body>
</html>
<head><metacontent="text/html;charset=utf-8"http-equiv="Content-Type"/><metacontent="/images/branding/googl
eg/1x/googleg_standard_color_128dp.png"itemprop="image"/><title>Google</title><scriptnonce="a9fEDiXswLfU_nPTD
CFxVQ">(function(){window.google={kEI:'W56uY5C4Ou7S1sQPn_6M6Ag',kEXPI:'0,1359409,6059,206,4804,2316,383,246,5,1
129120,1197703,698,380090,16114,28682,1109,21324,1361,12318,17581,4998,13228,3847,10623,22740,2370,2711,1593,12
79,2742,149,1103,841,2196,4101,108,4011,2023,2297,14670,3227,2845,7,4774,20215,4086,4695,1851,15756,3,576,1014,
1,5444,149,11323,2652,4,1528,2304,7039,22023,5708,7355,13660,4437,16786,5824,2533,4094,4052,3,3541,1,14263,2789
1,2,14022,2715,23024,5679,1021,2377,28745,4567,6256,23421,1252,5835,14968,4332,8,7476,445,2,2,1,6959,3998,15675
,8155,7381,2,1478,14490,872,19634,7,1922,5784,3995,21391,388,9543,4832,23189,3314,15605,4532,14,82,3890,757,868
6,6194,679,1622,782,997,668,3183,1125,1746,2041,4264,937,5903,1742,813,1224,10,280,2350,1497,2,32,531,909,82,10
01,1094,350,90,399,96,426,1034,42,291,2259,410,1649,1410,20,3,261,606,136,789,420,915,290,135,1304,246,951,841,
1378,947,857,74,29,203,1561,1422,149,234,71,3,539,77,9,512,326,226,156,327,9,323,50,53,166,6,258,767,184,394,10
87,164,1088,5,342,460,433,284,130,108,463,2,215,85,161,72,119,10,447,174,1068,69,857,340,500,62,118,1274,97,1,1
139,1570,49,8,538,529,77,101,38,425,36,12,105,1372,532,890,345,278,427,1199,104,191,218,544,196,3222,111,4,53,4
,40,2,355,17,179,87,1689,417,654,620,756,5272650,4190,8799060,3311,141,795,19735,1,1,346,3645,5,17,23946817,404
2143,1964,16672,3406,5595,11,3834,6974,224',kBL:'Dl4b'};google.sn='webhp';google.kHL='en-IN';})();(function(){
varf=this||self;varh,k=[];functionl(a){for(varb;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.paren
tNode;returnb||h}functionm(a){for(varb=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNod
e;returnb}
functionn(a,b,c,d,g){vare="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="
&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204
")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(goo
gle.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");returnc};h=google.kEI;google.getEI=l;google.getLEI=m;goo
gle.ml=function(){returnnull};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=newImage;vare=k.length;k[e
]=a;a.onerror=a.onload=a.onabort=function(){deletek[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){go
ogle.y={};google.sy=[];google.x=function(a,b){if(a)varc=a.id;else{doc=Math.random();while(google.y[c])}google
.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.pu
sh.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=funct
ion(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
document.documentElement.addEventListener("submit",function(b){vara;if(a=b.target){varc=a.getAttribute("data-
submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}elsea=!1;a&&(b.preventDefault(),b.stopPropagation(
))},!0);document.documentElement.addEventListener("click",function(b){vara;a:{for(a=b.target;a&&a!==document.d
ocumentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");breaka}a=!1}a&&b.pr
eventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px!important;}#gbar
{height:22px}#guser{padding-bottom:7px!important;text-align:right}.gbh,.gbd{border-top:1pxsolid#c9d7f1;font-
size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@mediaall{.gb1{height:22px;margin-right:.5em;vert
ical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline!important}a.gb1,a.gb4{color:#00c!impor
tant}.gbi.gb4{color:#dd8e27!important}.gbf.gb4{color:#900!important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px8px
0}td{line-height:.8em}.gac_mtd{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;f
ont-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18pxarial,sans-serif}.gsfs{font:17pxarial,sans-
serif}.ds{display:inline-box;display:inline-block;margin:3px04px;margin-left:4px}input{font-family:inherit}bo
dy{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.
fla{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblca{display:block;margin:2px0;margin-left
:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid1px;border-color:#dadce0#70757a#70757a#dadce0;hei
ght:30px}.lsbb{display:block}#WqQANba{display:inline-block;margin:012px}.lsb{background:url(/images/nav_logo2
29.png)0-261pxrepeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15pxarial,
sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><scriptnonce="a9f
EDiXswLfU_nPTDCFxVQ">(function(){window.google.erd={jsr:1,bv:1702,de:true};
varh=this||self;vark,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=func
tion(a,b,d,m,e){e=void0===e?2:e;b&&(r=a&&a.message);if(google.dl)returngoogle.dl(a,e,d),null;if(0>v){window.c
onsole&&console.error(a,d);if(-2===v)throwa;b=!1}elseb=!a||!a.message||"Errorloadingscript"===a.message||q>
=l&&!m?!1:!0;if(!b)returnnull;q++;d=d||{};b=encodeURIComponent;varc="/gen_204?atyp=i&ei="+b(google.kEI);googl
e.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);varf=a.li
neNumber;void0!==f&&(c+="&line="+f);varg=
a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.d
ocumentElement.outerHTML.split("\n")[f],c+="&cad="+b(f?f.substring(0,300):"Noscriptfound.")));c+="&jsel="+e;f
or(varuind)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+":"+a.message);c=c+"&jsst="+b(a.stack||"N
/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);returna};window.onerror=function(a,b,d,m
,e){r!==a&&(a=einstanceofError?e:Error(a),void0===d||"lineNumber"ina||(a.lineNumber=d),void0===b||"fileNam
e"ina||(a.fileName=b),google.ml(a,!1,void0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,1
1)||-1!==a.message.indexOf("Scripterror")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head>
<title>Google</title>
#viewtheheadofthesoupobject
#wehaveusedheadmethodtoviewtheheadofthewebpage
print(sl_soup.head)
#viewthetitleofthewebpage
#wehaveusedtitlemethodtoviewthetitleofthewebpage
sl_soup.title
#findallthelinkspresentonthewebpage
#hrefstoresthelinks
#aisthetaginhref
forhrefinsl_soup.findAll('a',href=True):
print(href['href'])
https://www.google.co.in/imghp?hl=en&tab=wi
https://maps.google.co.in/maps?hl=en&tab=wl
https://play.google.com/?hl=en&tab=w8
https://www.youtube.com/?tab=w1
https://news.google.com/?tab=wn
https://mail.google.com/mail/?tab=wm
https://drive.google.com/?tab=wo
https://www.google.co.in/intl/en/about/products?tab=wh
http://www.google.co.in/history/optout?hl=en
/preferences?hl=en
https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ
/advanced_search?hl=en-IN&authuser=0
https://www.google.com/url?q=https://about.google/stories/year-in-search/%3Futm_source%3Dgoogle%26utm_medium%3D
hpp%26utm_campaign%3DIndia_yis22&source=hpp&id=19033112&ct=3&usg=AOvVaw1jtvJixqyHY8bvEFRJBZJz&sa=X&ved=0ahUKEwj
Q0fq-86D8AhVuqZUCHR8_A40Q8IcBCAU
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=hi&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAc
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=bn&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAg
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=te&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAk
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=mr&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAo
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=ta&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAs
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=gu&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCAw
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=kn&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCA0
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=ml&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCA4
https://www.google.com/setprefs?sig=0_slLVMBe6sHLLGQLOG94MzmSLnNs%3D&hl=pa&source=homepage&sa=X&ved=0ahUKEwjQ0f
q-86D8AhVuqZUCHR8_A40Q2ZgBCA8
/intl/en/ads/
http://www.google.co.in/services/
/intl/en/about.html
https://www.google.com/setprefdomain?prefdom=IN&prev=https://www.google.co.in/&sig=K_O4lVvevQ8ETHggdm4IPsN1gvOO
8%3D
/intl/en/policies/privacy/
/intl/en/policies/terms/
#importthebostondatasetfromthesklearnlibrary
fromsklearn.datasetsimportload_boston
#importmatplotlib
importmatplotlib.pyplotasplt
frommatplotlibimportstyle
%matplotlibinline
#loadbostondataset
boston_real_state_data=load_boston()
#viewthebostondataset
boston_real_state_data
{'data':array([[6.3200e-03,1.8000e+01,2.3100e+00,...,1.5300e+01,3.9690e+02,
4.9800e+00],
[2.7310e-02,0.0000e+00,7.0700e+00,...,1.7800e+01,3.9690e+02,
9.1400e+00],
[2.7290e-02,0.0000e+00,7.0700e+00,...,1.7800e+01,3.9283e+02,
4.0300e+00],
...,
[6.0760e-02,0.0000e+00,1.1930e+01,...,2.1000e+01,3.9690e+02,
5.6400e+00],
[1.0959e-01,0.0000e+00,1.1930e+01,...,2.1000e+01,3.9345e+02,
6.4800e+00],
[4.7410e-02,0.0000e+00,1.1930e+01,...,2.1000e+01,3.9690e+02,
7.8800e+00]]),
'target':array([24.,21.6,34.7,33.4,36.2,28.7,22.9,27.1,16.5,18.9,15.,
18.9,21.7,20.4,18.2,19.9,23.1,17.5,20.2,18.2,13.6,19.6,
15.2,14.5,15.6,13.9,16.6,14.8,18.4,21.,12.7,14.5,13.2,
13.1,13.5,18.9,20.,21.,24.7,30.8,34.9,26.6,25.3,24.7,
21.2,19.3,20.,16.6,14.4,19.4,19.7,20.5,25.,23.4,18.9,
35.4,24.7,31.6,23.3,19.6,18.7,16.,22.2,25.,33.,23.5,
19.4,22.,17.4,20.9,24.2,21.7,22.8,23.4,24.1,21.4,20.,
20.8,21.2,20.3,28.,23.9,24.8,22.9,23.9,26.6,22.5,22.2,
23.6,28.7,22.6,22.,22.9,25.,20.6,28.4,21.4,38.7,43.8,
33.2,27.5,26.5,18.6,19.3,20.1,19.5,19.5,20.4,19.8,19.4,
21.7,22.8,18.8,18.7,18.5,18.3,21.2,19.2,20.4,19.3,22.,
20.3,20.5,17.3,18.8,21.4,15.7,16.2,18.,14.3,19.2,19.6,
23.,18.4,15.6,18.1,17.4,17.1,13.3,17.8,14.,14.4,13.4,
15.6,11.8,13.8,15.6,14.6,17.8,15.4,21.5,19.6,15.3,19.4,
17.,15.6,13.1,41.3,24.3,23.3,27.,50.,50.,50.,22.7,
25.,50.,23.8,23.8,22.3,17.4,19.1,23.1,23.6,22.6,29.4,
23.2,24.6,29.9,37.2,39.8,36.2,37.9,32.5,26.4,29.6,50.,
32.,29.8,34.9,37.,30.5,36.4,31.1,29.1,50.,33.3,30.3,
34.6,34.9,32.9,24.1,42.3,48.5,50.,22.6,24.4,22.5,24.4,
20.,21.7,19.3,22.4,28.1,23.7,25.,23.3,28.7,21.5,23.,
26.7,21.7,27.5,30.1,44.8,50.,37.6,31.6,46.7,31.5,24.3,
31.7,41.7,48.3,29.,24.,25.1,31.5,23.7,23.3,22.,20.1,
22.2,23.7,17.6,18.5,24.3,20.5,24.5,26.2,24.4,24.8,29.6,
42.8,21.9,20.9,44.,50.,36.,30.1,33.8,43.1,48.8,31.,
36.5,22.8,30.7,50.,43.5,20.7,21.1,25.2,24.4,35.2,32.4,
32.,33.2,33.1,29.1,35.1,45.4,35.4,46.,50.,32.2,22.,
20.1,23.2,22.3,24.8,28.5,37.3,27.9,23.9,21.7,28.6,27.1,
20.3,22.5,29.,24.8,22.,26.4,33.1,36.1,28.4,33.4,28.2,
22.8,20.3,16.1,22.1,19.4,21.6,23.8,16.2,17.8,19.8,23.1,
21.,23.8,23.1,20.4,18.5,25.,24.6,23.,22.2,19.3,22.6,
19.8,17.1,19.4,22.2,20.7,21.1,19.5,18.5,20.6,19.,18.7,
32.7,16.5,23.9,31.2,17.5,17.2,23.1,24.5,26.6,22.9,24.1,
18.6,30.1,18.2,20.6,17.8,21.7,22.7,22.6,25.,19.9,20.8,
16.8,21.9,27.5,21.9,23.1,50.,50.,50.,50.,50.,13.8,
13.8,15.,13.9,13.3,13.1,10.2,10.4,10.9,11.3,12.3,8.8,
7.2,10.5,7.4,10.2,11.5,15.1,23.2,9.7,13.8,12.7,13.1,
12.5,8.5,5.,6.3,5.6,7.2,12.1,8.3,8.5,5.,11.9,
27.9,17.2,27.5,15.,17.2,17.9,16.3,7.,7.2,7.5,10.4,
8.8,8.4,16.7,14.2,20.8,13.4,11.7,8.3,10.2,10.9,11.,
9.5,14.5,14.1,16.1,14.3,11.7,13.4,9.6,8.7,8.4,12.8,
10.5,17.1,18.4,15.4,10.8,11.8,14.9,12.6,14.1,13.,13.4,
15.2,16.1,17.8,14.9,14.1,12.7,13.5,14.9,20.,16.4,17.7,
19.5,20.2,21.4,19.9,19.,19.1,19.1,20.1,19.9,19.6,23.2,
29.8,13.8,13.3,16.7,12.,14.6,21.4,23.,23.7,25.,21.8,
20.6,21.2,19.1,20.6,15.2,7.,8.1,13.6,20.1,21.8,24.5,
23.1,19.7,18.3,21.2,17.5,16.8,22.4,20.6,23.9,22.,11.9]),
'feature_names':array(['CRIM','ZN','INDUS','CHAS','NOX','RM','AGE','DIS','RAD',
'TAX','PTRATIO','B','LSTAT'],dtype='<U7'),
'DESCR':".._boston_dataset:\n\nBostonhousepricesdataset\n---------------------------\n\n**DataSetCharac
teristics:**\n\n:NumberofInstances:506\n\n:NumberofAttributes:13numeric/categoricalpredictiv
e.MedianValue(attribute14)isusuallythetarget.\n\n:AttributeInformation(inorder):\n-CRIM
percapitacrimeratebytown\n-ZNproportionofresidentiallandzonedforlotsover25,000sq.
ft.\n-INDUSproportionofnon-retailbusinessacrespertown\n-CHASCharlesRiverdumm
yvariable(=1iftractboundsriver;0otherwise)\n-NOXnitricoxidesconcentration(partsper
10million)\n-RMaveragenumberofroomsperdwelling\n-AGEproportionofowner-oc
cupiedunitsbuiltpriorto1940\n-DISweighteddistancestofiveBostonemploymentcentres\n
-RADindexofaccessibilitytoradialhighways\n-TAXfull-valueproperty-taxrateper$10,0
00\n-PTRATIOpupil-teacherratiobytown\n-B1000(Bk-0.63)^2whereBkisthepropor
tionofblackpeoplebytown\n-LSTAT%lowerstatusofthepopulation\n-MEDVMedianva
lueofowner-occupiedhomesin$1000's\n\n:MissingAttributeValues:None\n\n:Creator:Harrison,D.and
Rubinfeld,D.L.\n\nThisisacopyofUCIMLhousingdataset.\nhttps://archive.ics.uci.edu/ml/machine-learning-d
atabases/housing/\n\n\nThisdatasetwastakenfromtheStatLiblibrarywhichismaintainedatCarnegieMellonU
niversity.\n\nTheBostonhouse-pricedataofHarrison,D.andRubinfeld,D.L.'Hedonic\npricesandthedemandf
orcleanair',J.Environ.Economics&Management,\nvol.5,81-102,1978.UsedinBelsley,Kuh&Welsch,'Regr
essiondiagnostics\n...',Wiley,1980.N.B.Varioustransformationsareusedinthetableon\npages244-261o
fthelatter.\n\nTheBostonhouse-pricedatahasbeenusedinmanymachinelearningpapersthataddressregress
ion\nproblems.\n\n..topic::References\n\n-Belsley,Kuh&Welsch,'Regressiondiagnostics:Identif
yingInfluentialDataandSourcesofCollinearity',Wiley,1980.244-261.\n-Quinlan,R.(1993).CombiningIn
stance-BasedandModel-BasedLearning.InProceedingsontheTenthInternationalConferenceofMachineLearning
,236-243,UniversityofMassachusetts,Amherst.MorganKaufmann.\n",
'filename':'boston_house_prices.csv',
'data_module':'sklearn.datasets.data'}
#definexaxisforthedata
x_axis=boston_real_state_data.data
year month passengers
0 1949 Jan 112
1 1949 Feb 118
2 1949 Mar 132
3 1949 Apr 129
4 1949 May 121
year 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
month
Jan 112 115 145 171 196 204 242 284 315 340 360 417
Feb 118 126 150 180 196 188 233 277 301 318 342 391
Mar 132 141 178 193 236 235 267 317 356 362 406 419
Apr 129 135 163 181 235 227 269 313 348 348 396 461
May 121 125 172 183 229 234 270 318 355 363 420 472
Jun 135 149 178 218 243 264 315 374 422 435 472 535
Jul 148 170 199 230 264 302 364 413 465 491 548 622
Aug 148 170 199 242 272 293 347 405 467 505 559 606
Sep 136 158 184 209 237 259 312 355 404 404 463 508
Oct 119 133 162 191 211 229 274 306 347 359 407 461
Nov 104 114 146 172 180 203 237 271 305 310 362 390
Dec 118 140 166 194 201 229 278 306 336 337 405 432
<AxesSubplot:xlabel='year',ylabel='month'>
#defineyaxisforthedata
y_axis=boston_real_state_data.target
frommatplotlibimportuse
#plothistogram
style,use('ggplot')
plt.figure(figsize=(7,7))
plt.hist(y_axis,bins=50)
plt.xlabel('pricein1000sUSD')
plt.ylabel('numberofhouses')
plt.show()
#plotscatterplot
style,use('ggplot')
plt.figure(figsize=(7,7))
plt.scatter(boston_real_state_data.data[:,5],boston_real_state_data.target)
plt.xlabel('pricein1000sUSD')
plt.ylabel('numberofhouses')
plt.show()
#importmatplotlibrary
importmatplotlib.pyplotasplt
#importseabornlibrary
importseabornassns
#toshowplotonnotebook
%matplotlibinline
#loadflightsdatafromsnsdatasetthatisbuiltin
flight_data=sns.load_dataset('flights')
#viewtop5records
flight_data.head()
#usepivotmethodtorearangethedataset
flight_data=flight_data.pivot('month','year','passengers')
flight_data
#useheatmapmethodtogeneratetheheatmapoftheflightdata
sns.heatmap(flight_data)
#importrequiredlibraries
importmatplotlib.pyplotasplt
%matplotlibinline
#jobdatainpercentile
job_data=['10','20','30','40','50']
#definelabelasdifferentdepartments
labels='IT','Finance','Marketing','Admin','HR'
#explodethe1stslicewhichisIT
explode=(0.05,0,0,0,0)
#drawthepiechartandsettheparameters
plt.pie(job_data,labels=labels,explode=explode)
#showtheplot
plt.show()
#importrequiredlibraries
#use%matplotlibinlinetodisplayorviewtheplotonjupyternotebook
importmatplotlib.pyplotasplt
frommatplotlibimportstyle
%matplotlibinline
#websitetrafficdata
#numberofusers/visitorsonthewebsite
web_customers=[1,2,3,4,5,6,7,8,9,10]-#thisisthelistofusers
#timedistributionbyhourly
time_hrs=[11,12,13,14,15,16,17,18,19,20]-#thisisthetime
#selectthestyleoftheplot
style.use('ggplot')
[<matplotlib.lines.Line2Dat0x1bb4706edf0>]
#plotthewebsitetrafficdatathatisxaxisasthehoursandtheyaxisasthenumberofusers
plt.plot(time_hrs,web_customers)
#setthetitleoftheplot
plt.title('websittraffic')
#setthelabelforxaxis
plt.xlabel('hrs')
#setthelabelforyaxis
plt.ylabel('numberofusers')
#showtheplot
plt.show()
#importrequiredlibraries
importmatplotlib.pyplotasplt
frommatplotlibimportstyle
%matplotlibinline
#definetemp,wind,humidity,precipitationdataandtimehrsdata
#herewehavecreatedthedatafortemperature,wind,time,humidityandtheprecipitation
temp_data=[67,77,65,34,68,87,56,44,90,90]
wind_data=[2,5,6,7,8,12,13,14,15,16]
time_hrs=[1,2,3,4,5,6,7,8,9,10]
humidity_data=[33,45,67,88,99,90,87,65,43,21]
precipitation_data=[23,23,45,34,56,57,65,43]
#drawsuplotfor(1,2,1)and(1,2,2)
#Figsizeisamethodfromthepyplotclasswhichallowsyoutochangethedimensionsofthegraph.
#hpaceis
#linewidthisusedtomaintainthespecificwidthoftheline
#colorisusedtogivethecolorofthelineinthegraph
#linestyleisusedastogivetheformatofthelinetodisplaythelineonthegrapgh
plt.figure(figsize=(8,4))
plt.subplots_adjust(hspace=.25)
plt.subplot(1,2,1)
plt.title('Temp')
plt.plot(time_hrs,temp_data,color='b',linestyle='-',linewidth=1)
plt.subplot(1,2,2)
plt.title('wind')
plt.plot(time_hrs,wind_data,color='r',linestyle='-',linewidth=1)
[<matplotlib.lines.Line2Dat0x1bb471427f0>]
#drawsuplotfor(2,1,1)and(2,1,2)
plt.figure(figsize=(6,6))
plt.subplots_adjust(hspace=.25)
plt.subplot(2,1,1,)
plt.title('Humidity')
plt.plot(time_hrs,temp_data,color='b',linestyle='-',linewidth=1)
plt.subplot(2,1,2)
plt.title('Precipitation')
plt.plot(time_hrs,wind_data,color='r',linestyle='-',linewidth=1)
#drawsuplotfor(2,2,1)and(2,2,2),(2,2,3),(2,2,4)
#drawsuplotfor(2,2,1)and(2,2,2),(2,2,3),(2,2,4)
plt.figure(figsize=(9,9))
plt.subplots_adjust(hspace=.3)
plt.subplot(2,2,1,)
plt.title('temp(F)')
plt.plot(time_hrs,temp_data,color='b',linestyle='-',linewidth=1)
plt.subplot(2,2,2)
plt.title('wind(MPH)')
plt.plot(time_hrs,wind_data,color='r',linestyle='-',linewidth=1)
plt.subplot(2,2,3)
plt.title('humidity(%)')
plt.plot(time_hrs,humidity_data,color='g',linestyle='-',linewidth=1)
plt.subplot(2,2,2)
plt.title('precipitation(%)')
plt.plot(time_hrs,precipitation_data,color='y',linestyle='-',linewidth=1)
plt.show()
#importtherequiredlibraries
importpandasaspd
importmatplotlib.pyplotasplt
importseabornassns
#toviewtheplotinthejupyternotebook
%matplotlibinline
#importtheautodataset
df_auto_dataset=pd.read_csv("auto_data_mpg.csv")
#viewthetop5records
df_auto_dataset.head()
mpg cylinders displacement horsepower weight acceleration model_year origin name
0 18.0 8 307.0 130 3504 12.0 70 1 chevroletchevellemalibu
1 15.0 8 350.0 165 3693 11.5 70 1 buickskylark320
2 18.0 8 318.0 150 3436 11.0 70 1 plymouthsatellite
3 16.0 8 304.0 150 3433 12.0 70 1 amcrebelsst
4 17.0 8 302.0 140 3449 10.5 70 1 fordtorino
Index(['mpg','cylinders','displacement','horsepower','weight',
'acceleration','model_year','origin','name'],
dtype='object')
0USA
1USA
2USA
3USA
4USA
...
393USA
394Europe
395USA
396USA
397USA
Name:origin,Length:398,dtype:object
mpg cylinders displacement horsepower weight acceleration model_year origin name
0 18.0 8 307.0 130 3504 12.0 70 USA chevroletchevellemalibu
1 15.0 8 350.0 165 3693 11.5 70 USA buickskylark320
2 18.0 8 318.0 150 3436 11.0 70 USA plymouthsatellite
3 16.0 8 304.0 150 3433 12.0 70 USA amcrebelsst
4 17.0 8 302.0 140 3449 10.5 70 USA fordtorino
C:\Users\Ankita\anaconda3\lib\site-packages\seaborn\axisgrid.py:2076:UserWarning:The`size`parameterhasbee
nrenamedto`height`;pleaseupdateyourcode.
warnings.warn(msg,UserWarning)
<seaborn.axisgrid.PairGridat0x1bb4a8e3670>
#columnspresentinthedatasetaredisplayed
df_auto_dataset.columns
#writeauserdefinedfunctionfororigin
#1-USA,2-Europe,3-Asia
deforigin(num):
ifnum==1:
return'USA'
elifnum==2:
return'Europe'
else:
return'Asia'

#useapplyfunction
df_auto_dataset['origin']=df_auto_dataset['origin'].apply(origin)
#usedapplyfunction
df_auto_dataset['origin']
#viewfirst30datapointsafterapplyingtheuserdefinedfunctiontothedataset
df_auto_dataset.head()
#drawthepairplotusingsnsformpg,wightandoriginandwithhueorigin,setthesizeto4
#note:hueisthevariableinthedatasettomapplotaspectstothedifferentcolour.
sns.pairplot(df_auto_dataset[['mpg','weight','origin']],size=4)
#featurereduction
#importtheload_irisfromthesklearndataset
#load_irisistheinbuiltdatasetinthesklearnlibrary
importsklearn
fromsklearn.datasetsimportload_iris
#wewillsetthedatasetnowtotheloadeddata
data=load_iris()
#definexandyasthetrainingandthetargetvariablesrespectively
x=data.data
y=data.target
#nowwewillusethemodel_selectionmodulewithinthesklearnlibrary
#importthetraintestsplitfunction
#traintestsplittakesthedataandsplitsitintotrainingandtestdataset
fromsklearn.model_selectionimporttrain_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=1)
#theshapemethodwillgivethesizeofthetrainingdataspecificallynumberofrowsandcolumns
(120,4)
C:\Users\Ankita\anaconda3\lib\site-packages\sklearn\linear_model\_logistic.py:814:ConvergenceWarning:lbfgsfa
iledtoconverge(status=1):
STOP:TOTALNO.ofITERATIONSREACHEDLIMIT.
Increasethenumberofiterations(max_iter)orscalethedataasshownin:
https://scikit-learn.org/stable/modules/preprocessing.html
Pleasealsorefertothedocumentationforalternativesolveroptions:
https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
n_iter_i=_check_optimize_result(
LogisticRegression()
0.9666666666666667
PCA(n_components=0.95)
(120,2)
(30,4)
(30,2)
#theshapemethodwillgivethesizeofthetrainingdataspecificallynumberofrowsandcolumns
print(x_train.shape)
#nowpulloutthelogicticregressionclassifieroutofthesklearnlibrary
#aslogicticregressionwillbetheperfectclassifierfor01tragetsvalues
fromsklearn.linear_modelimportLogisticRegression
#settingthevariableforlogicticregressionaslr
lr=LogisticRegression()
#aftercreatingthevariablelrfitthemodeloverthexandytrainingset
lr.fit(x_train,y_train)
#nowwewillusethepredictfunctiononthexandytestingsettopredictthepossibleoutcomes
y_predict=lr.predict(x_test)
#noewewillcomparethepredictedoutcomeswiththeactaulvalues
#wewillbepredictingthepowerofourmodel
#forcomparingthepredictedoutcomesandtheactualvalues
#andthiscanbedonebytheaccuracy_scorefunctionunderthesklearn.metricslibrary
fromsklearn.metricsimportaccuracy_score
accuracy=accuracy_score(y_predict,y_test)
#printingtheaccuracyofthemodel
#astheaccuracyis96%themodelisapproximatelyaccurate
#buttogetthe100%accuracytheabovefeaturescanbeadjusted
print(accuracy)
#importthePCAmodulefromthesklearn.decomposition
fromsklearn.decompositionimportPCA
#herepcawillreducethenumberofcomponentsorigiallypresentinourdatatoacertainnumber
#suchthatitexplainthe95%ofthevariance
sklearn_pca=PCA(n_components=0.95)
#fittingPCAonourtrainingdata
sklearn_pca.fit(x_train)
#fittingPCAonourtrainingdata
#herenewvariablecalledx_train_transformediscreated
x_train_transformed=sklearn_pca.transform(x_train)
#nowwewillchecktheshapeoftheresultingdata
print(x_train_transformed.shape)
#transformingthetestingset
print(x_test.shape)
#wewillusethetransformfunctionagaintotransformthetestingdata
x_train_transformed=sklearn_pca.transform(x_test)
print(x_train_transformed.shape)
#seeingtheoutputbyusingthetransformedfunction
x_train_transformed=sklearn_pca.transform(x_test)
#printingthex_train_transformed
print(x_train_transformed)
[[-2.687389671.24153895]
[-0.96538559-0.70916231]
[0.848759810.36063236]
[-2.6677610.87375109]
[3.188814991.39096721]
[1.045630260.31741614]
[1.874757270.42737639]
[-2.256841390.50141011]
[-2.68626909-0.12972275]
[2.379965570.39664779]
[0.29972026-0.46441361]
[-2.325935340.80416676]
[2.566397310.3617593]
[0.882476890.35216014]
[0.7592687-0.12787235]
[-3.05198739-0.2718511]
[0.17301658-0.3648974]
[0.60593977-0.31331324]
[-2.459197250.47071942]
[-2.918745690.13417817]
[0.40549318-0.62879833]
[0.5330404-0.44285763]
[1.506609210.29454543]
[-2.819659420.32889825]
[2.564581820.58291385]
[0.24318335-0.30859743]
[-2.640886271.159726]
[-2.634887450.57982198]
[0.86550017-0.14505759]
[1.4709022-0.35043795]]
#nowthatwehavetransformedfeaturesusingPCA.
#letsimplementthemodelonceagainoverthetransformeddatasetandchecktheresults
lr=LogisticRegression(penalty='l1')
#fitthelogisticregressionmodeloverthetransformeddataset
lr.fit(x_train_transformed,y_train)
#nowwewillusethepredictfunctionontehetransformeddata
y_predict=lr.predict(x_test_transformed)
#nowchecktheaccuracytotheaccuracyofthemodel
accuracy=accuracy_score(y_predict,y_test)
#printingtheaccuracy
print(accuracy)